package com.peanut.youfupay.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Slf4j
@Configuration
public class IdWorkerConfig {
    @Value("${dataCenter.Id:1}")
    private long dataCenterId;
    @Value("${dataCenter.workerId:1}")
    private long workerId;

    @Bean
    public synchronized IdWorkerBySnowFlake buildIdWorker() {
        IdWorkerBySnowFlake snowflake = new IdWorkerBySnowFlake(dataCenterId, workerId);
        return snowflake;
    }
}
